package com.nf.health.app.myfamily.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.ListView;
import android.widget.TextView;

import com.nf.health.app.R;
import com.nf.health.app.activity.global.BaseActivity;
import com.nf.health.app.adapter.DataDetailsHistoryAdapter;
import com.nf.health.app.utils.ViewUtil;

import java.util.ArrayList;

/**
 * @ClassName: DataDetailsHistoryActivity
 * @Description: 健康数据历史记录
 * @author Ian
 * @date 2015-11-4 上午9:47:29
 *
 */
public class DataDetailsHistoryActivity extends BaseActivity {

	private ListView lv_datadetails_history;
	private ArrayList<String> yValues = new ArrayList<String>();
	public ArrayList<String> xValues = new ArrayList<String>();
	private DataDetailsHistoryAdapter adapter;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setTitleBar(R.layout.titlebar_base);
		setContent(R.layout.activity_datadetailshistory);
		TextView titleTV = (TextView) findViewById(R.id.titlebar_title_tv);
		titleTV.setText("健康数据");
		lv_datadetails_history = (ListView) findViewById(R.id.lv_datadetails_historyId);

		String title = getIntent().getStringExtra("title");
		ViewUtil.setText(this, R.id.titlebar_title_tv, title);

		ArrayList<String> xValuesTemp = getIntent().getStringArrayListExtra("xValues");
		ArrayList<String> yValuesTemp = getIntent().getStringArrayListExtra("yValues");
		if(xValuesTemp == null && yValuesTemp == null){
			return;
		}
		xValues.add(0,"时间");
		xValues.addAll(xValuesTemp);
		String unit = getIntent().getStringExtra("unit");
		if(TextUtils.isEmpty(unit)){
			yValues.add("数据");
		}else{
			yValues.add("数据("+unit+")");
		}

		yValues.addAll(yValuesTemp);

		adapter = new DataDetailsHistoryAdapter(this, yValues, xValues);
		lv_datadetails_history.setAdapter(adapter);
	}
}
